//
//  NSString+LX.m
//  tableViewOptimize
//
//  Created by imera on 16/5/9.
//  Copyright © 2016年 LX. All rights reserved.
//

#import "NSString+LX.h"

@implementation NSString (LX)

/** 根据文字动态调整宽高 */
+ (CGSize)rectWithString:(NSString *)string strFont:(UIFont *)strFont maxWidth:(CGFloat)maxWidth
{
    CGSize size = [string sizeWithAttributes:@{NSFontAttributeName:strFont}];
    int rowNum = size.width / maxWidth + 1;
    return CGSizeMake(maxWidth, rowNum * size.height);
}

- (CGSize)rectWithFont:(UIFont *)strFont maxWidth:(CGFloat)maxWidth
{
    CGSize size = [self sizeWithAttributes:@{NSFontAttributeName:strFont}];
    int rowNum = size.width / maxWidth + 1;
    return CGSizeMake(maxWidth, rowNum * size.height);
}
@end
